package com.company;


public class Task1 {


    public static void main(String[] args) {
        //todo 1.统计一个字符串里面另一个字符串出现的次数，例如统计"monkey"在"I am monkey1024.monkey like banana.little monkey is smart."中出现的次数.
        String str = "I am monkey1024.monkey like banana.little monkey is smart.";
        String str1 = "monkey";
        int start = 0;
        int count = 0;
        while (str.indexOf(str1, start) >= 0 && start < str.length()) {
            count++;
            start = str.indexOf(str1, start) + str1.length();
        }
        System.out.println(str1 + "在" + str + "出现的次数为" + count);

    }

}
